<template>
  <div class="t-radio">
    <el-checkbox
      v-for="item in options"
      :key="item.value"
      v-model="moduleValue"
      false-label=""
      :true-label="item.value"
      :disabled="disabled"
      @input="handleChange"
      >{{ item.label }}</el-checkbox
    >
  </div>
</template>
<script>
export default {
  name: "TRadio",
  props: {
    value: {
      type: [String, Number],
      default: "",
      require: true,
    },
    options: {
      type: Array,
      default: () => [],
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  computed: {
    moduleValue: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("input", val);
      },
    },
  },
  methods: {
    focus() {
      const select = this.$refs.select;
      if (select) {
        select.focus();
      }
    },
    handleChange(value) {
      this.$emit("change", value);
    },
  },
};
</script>
<style lang="scss" scoped>
.t-radio {
  display: flex;
  justify-content: space-around;
  ::v-deep {
    .el-checkbox__inner {
      border-radius: 50%;
      &::after {
        content: "";
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background-color: #fff;
        border: none;
        position: absolute;
        left: 50%;
        top: 50%;
        transition: transform 0.15s ease-in;
        transform: translate(-50%, -50%) scale(1);
      }
    }
    .el-checkbox__input.is-disabled {
      .el-checkbox__inner::after {
        transform: translate(-50%, -50%) scale(0);
      }
      &.is-checked {
        .el-checkbox__inner::after {
          background-color: #c0c4cc;
          transform: translate(-50%, -50%) scale(1);
        }
      }
    }
  }
}
</style>
